<template>
	<view>
		<view class="head">
			<view class="head_left" @tap="back()">
				<image src="../../../static/wode/return.png" mode=""></image>
				<text>返回</text>
			</view>
			<view class="head_mid">
				隐私
			</view>
			<view class="head_right">

			</view>
		</view>
		<view class="body">
			<view class="body_item">
				<text>可通过手机号找到我</text>
				<switch :checked="is_mobile" @change="changMob" />
			</view>
			<view class="body_item">
				<text>可通过ID找到我</text>
				<switch :checked="is_id" @change="changId" />
			</view>
			<view class="body_item">
				<text>可通过昵称找到我</text>
				<switch :checked="is_name" @change="changName" />
			</view>
			<view class="body_item">
				<text>可通过邮箱找到我</text>
				<switch :checked="is_mail" @change="changMail" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				is_id: '',
				is_mail: '',
				is_mobile: '',
				is_name: '',
			};
		},
		onShow() {
			this.getuser()
		},
		methods: {
			back() { //返回
				uni.navigateBack({
					delta: 1
				})
			},
			getuser() {
				var me = this;
				var data = {
					user_id: uni.getStorageSync('user_id')
				}
				this.myAjaxNew({
					model: 'user',
					controllerName: "userInfo",
					actionName: 'queryUserInfoById',
					data: data,
					successBack: function(res) {
						console.log(res)
						me.is_id = res.data.data.userInfoEntity.is_id;
						me.is_mail = res.data.data.userInfoEntity.is_mail;
						me.is_mobile = res.data.data.userInfoEntity.is_mobile;
						me.is_name = res.data.data.userInfoEntity.is_name;
					}
				})
			},
			changMob() {
				if (this.is_mobile == false) {
					this.is_mobile = true
				} else {
					this.is_mobile = false
				}
				var data = {
					is_mobile: this.is_mobile
				}
				this.myAjaxNewPost({
					model: 'user',
					controllerName: "userInfo",
					actionName: 'update',
					data: data,
					successBack: function(res) {
						console.log(res)
					},
				})
			},
			changId() {
				if (this.is_id == false) {
					this.is_id = true
				} else {
					this.is_id = false
				}
				var data = {
					is_id: this.is_id
				}
				this.myAjaxNewPost({
					model: 'user',
					controllerName: "userInfo",
					actionName: 'update',
					data: data,
					successBack: function(res) {
						console.log(res)
					},
				})
			},
			changName() {
				if (this.is_name == false) {
					this.is_name = true
				} else {
					this.is_name = false
				}
				var data = {
					is_name: this.is_name
				}
				this.myAjaxNewPost({
					model: 'user',
					controllerName: "userInfo",
					actionName: 'update',
					data: data,
					successBack: function(res) {
						console.log(res)
					},
				})
			},
			changMail() {
				if (this.is_mail == false) {
					this.is_mail = true
				} else {
					this.is_mail = false
				}
				var data = {
					is_mail: this.is_mail
				}
				this.myAjaxNewPost({
					model: 'user',
					controllerName: "userInfo",
					actionName: 'update',
					data: data,
					successBack: function(res) {
						console.log(res)
					},
				})
			},
		},
	}
</script>

<style scoped>
	.head {
		width: 100%;
		display: flex;
		justify-content: space-between;
		height: 162upx;
		background: #ffffff;
		padding: 0 24upx;
		z-index: 200;
	}

	.head image {
		width: 20upx;
		height: 36upx;
		margin-right: 9upx;
	}

	.head_left {
		height: 82upx;
		width: 106upx;
		display: flex;
		align-items: center;
		line-height: 82upx;
		color: #666666;
		font-size: 32upx;
		padding-top: 70upx;
	}
	.head_mid{
		padding-top: 90upx;
	}

	.head_right {
		width: 150upx;
	}

	.body {
		margin-top: 20upx;
		background: #FFFFFF;
		font-size: 32upx;
	}

	.body_item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1upx solid #E6E6E6;
		padding: 24upx 24upx;
	}
</style>
